package com.hospital.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hospital.domain.pojo.Schedule;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface ScheduleMapper extends BaseMapper<Schedule> {
    
    @Select("SELECT s.*, d.dname, d.dtitle, d.dmajor, dep.depName " +
            "FROM schedule s " +
            "LEFT JOIN doctor d ON s.dId = d.did " +
            "LEFT JOIN department dep ON s.depId = dep.depId " +
            "ORDER BY s.date DESC, s.time")
    List<Map<String, Object>> queryAllSchedulesWithDoctorInfo();
    
    @Select("SELECT s.*, d.dname, d.dtitle, d.dmajor, dep.depName " +
            "FROM schedule s " +
            "LEFT JOIN doctor d ON s.dId = d.did " +
            "LEFT JOIN department dep ON s.depId = dep.depId " +
            "WHERE s.dId = #{dId} " +
            "ORDER BY s.date DESC, s.time")
    List<Map<String, Object>> querySchedulesByDoctorWithInfo(Integer dId);
}
